package com.hq.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hq.service.CPService;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class CPController {
    @Resource
    CPService cpService;

    @RequestMapping("/list.do")
    public String list(@RequestParam(defaultValue = "1")Integer pageNum , Model model,
                       String cname,
                       String pricesx,
                       String pricesd){
        Page<Object> page = PageHelper.startPage(pageNum, 5);
        List list=cpService.list(cname,pricesx,pricesd);
        model.addAttribute("list",list);
        model.addAttribute("page",page);
        model.addAttribute("cname",cname);
        model.addAttribute("pricesx",pricesx);
        model.addAttribute("pricesd",pricesd);
        return "list";
    }
}
